// components/store-picker/store-picker.js
Component({
  properties: {
    // 组件属性
  },

  data: {
    latitude: 39.90469, // 默认北京
    longitude: 116.40717,
    markers: [],
    stores: [
      {
        id: 1,
        name: 'TDesign旗舰店',
        distance: '1.2km',
        address: '北京市朝阳区建国路88号TDesign大厦1层',
        hours: '营业时间：08:00-22:00',
        open: true,
        latitude: 39.90469,
        longitude: 116.40717
      },
      // 更多门店数据...
    ],
    currentStoreIndex: 0,
    filterIndex: 0,
    searchText: ''
  },

  methods: {
    onStoreTap(e) {
      const index = e.currentTarget.dataset.index;
      this.setData({
        currentStoreIndex: index
      });
      
      // 地图中心移动到选中门店
      const store = this.data.stores[index];
      this.setData({
        latitude: store.latitude,
        longitude: store.longitude
      });
    },
    
    onFilterTap(e) {
      const index = e.currentTarget.dataset.index;
      this.setData({
        filterIndex: index
      });
      
      // 这里可以添加筛选逻辑
    },
    
    onSearchInput(e) {
      this.setData({
        searchText: e.detail.value
      });
      
      // 这里可以添加搜索过滤逻辑
    },
    
    onLocationTap() {
      // 获取当前位置
      wx.getLocation({
        type: 'gcj02',
        success: (res) => {
          this.setData({
            latitude: res.latitude,
            longitude: res.longitude
          });
        }
      });
    },
    
    scrollToSelected() {
      // 滚动到已选门店
    },
    
    onConfirm() {
      const store = this.data.stores[this.data.currentStoreIndex];
      this.triggerEvent('confirm', { store });
    }
  }
})